package com.mop.service;

import com.mop.mapper.RewardMapper;
import com.mop.pojo.Reward;
import com.mop.vo.PageResult;
import com.mop.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RewardServiceImpl implements RewardService{
    @Autowired
    private RewardMapper rewardMapper;




    @Override
    public void addReward(Reward reward) {
        rewardMapper.addReward(reward);
    }

    @Override
    public PageResult getFind(PageResult pageResult) {
        //1.获取记录总和
        long total=rewardMapper.findCount();
        //2.获取分页查询
        int size =pageResult.getPageSize();//条数
        int start=(pageResult.getPageNum()-1)*size;
        String query=pageResult.getQuery();//查询条件
        List<Reward> list= rewardMapper.findRewardLimit(query,start,size);
        pageResult.setTotal(total).setRows(list);
        return pageResult;

    }

    @Override
    public void deleteReward(Reward reward) {
        rewardMapper.deleteReward(reward);
    }
}
